<#include "/common/layout_dl.html">
<@header>
</@header>
<@body>
<form class="form-horizontal layui-form layui-form-pane" method="post" action="/projects/job/doAdd">
   <div class="box-body">
     <div class="form-group">
       <label for="uname" class="col-sm-2 control-label">项目名</label>
       <div class="col-sm-10">
      		<input type="text" id="uname" name="jobName" class="form-control" placeholder="请输入项目名" lay-verify="required" check-url="/projects/job/checkName">
     	</div>
     </div>
       <div class="form-group">
       <label for="uname" class="col-sm-2 control-label">描述</label>
       <div class="col-sm-10">
      		<input type="text" id="desc" name='desc'  class="form-control" placeholder="请输入项目描述" lay-verify="required" >
     	</div>
     </div>
     
     <div class="form-group">
           <label class="col-sm-2 control-label">模板</label>
           <div class="col-sm-10">
           <select  id="tpl" name="tplId" class="form-control select2" lay-ignore style="width: 100%;" lay-verify="required">
            <option value="">请选择模板</option>
            <#list tplList as tpl>
              <option value="${(tpl.id)!}">${(tpl.desc)!}</option>
            </#list>
          </select>
          </div>
        </div>
    
     <div class="form-group">
            <label class="col-sm-2 control-label">流水线脚本</label>
             <div class="col-sm-10">
            <textarea id="ps" class="form-control" name="pipelineScript" lay-verify="required" rows="20"  >${(tpl.pipelineScript)!}</textarea>
          	</div>
          </div>
    
         <div class="form-group">
         		<label class="col-sm-2 control-label">&nbsp;</label>
         		 <div class="col-sm-10">
         		 	<button type="submit" class="btn btn-success" lay-submit lay-filter="submit"><i class="fa fa-save"></i>  提 交</button>
   		  </div>
         </div>
     </div><!-- /.box-body -->
 </form>

</@body>
<@footer>
 <script>
$("#tpl").on('change',function(){
	
	var id = $(this).val();
	 $.post('/projects/job/json?_dc='+new Date().getTime(),{id:id},function(response){
		if(response.code==200){
			console.log(response.data[0].script)
			$("#ps").empty();
			$("#ps").val(response.data[0].script);
		}
	}); 
});
</script>
</@footer>